<template>
  <div class="mt-3">
    <a-form layout="inline">
      <a-form-item label="资源类型">
        <a-select
          style="width: 150px"
          placeholder="请选择资源类型"
          v-model:value="resourceType"
          :options="resourceTypeOptions"
        />
      </a-form-item>
      <a-form-item>
        <a-button type="primary" @click="onSearch">查询</a-button>
      </a-form-item>
    </a-form>
    <a-table
      :columns="columns"
      :data-source="dataSource"
      :pagination="pagination"
      class="mt-5"
    />
  </div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue';
import { importCustomerHistory_two } from '#/api/core/customerInformation';

const resourceType = ref('');
const resourceTypeOptions = ref([
  {
    label: '小区',
    value: '小区',
  },
  {
    label: '房间',
    value: '房间',
  },
]);
const dataSource = ref([]);
const columns = [
  {
    title: '资源名称',
    dataIndex: 'resourceName',
    key: 'resourceName',
    align: 'center',
  },
  {
    title: '资源类型',
    dataIndex: 'migrationType',
    key: 'migrationType',
    align: 'center',
  },
  {
    title: '原所属资源',
    dataIndex: 'originalBelongResource',
    key: 'originalBelongResource',
    align: 'center',
  },
  {
    title: '现所属资源',
    dataIndex: 'currentBelongResource',
    key: 'currentBelongResource',
    align: 'center',
  },
  {
    title: '状态',
    dataIndex: 'migrationSituation',
    key: 'migrationSituation',
    align: 'center',
  },
  {
    title: '迁移情况',
    dataIndex: 'state',
    key: 'state',
    align: 'center',
  },
  {
    title: '开始时间',
    dataIndex: 'startTime',
    key: 'startTime',
    align: 'center',
  },
  {
    title: '结束时间',
    dataIndex: 'endTime',
    key: 'endTime',
    align: 'center',
  },
  {
    title: '操作人',
    dataIndex: 'operatorName',
    key: 'operatorName',
    align: 'center',
  },
];
const pagination = reactive({
  total: 0,
  pageSize: 10,
  current: 1,
  showSizeChanger: true,
  showQuickJumper: true,
  showTotal: (total: number) => `共 ${total} 条`,
  onChange: (page: number, pageSize: number) => {
    pagination.current = page;
    pagination.pageSize = pageSize;
    // onSearch();
  },
});
const onSearch = () => {
  const query = {
    resourceType: resourceType.value,
    page: pagination.current,
    limit: pagination.pageSize,
  };
  importCustomerHistory_two(query).then((res: any) => {
    // console.log(res);
    dataSource.value = res.data.data;
    pagination.total = res.data.count;
  });
};
</script>
<style scoped></style>
